package com.ruoyi.web.controller.basicInfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basicInfo.domain.Dumper;
import com.ruoyi.basicInfo.service.IDumperService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 翻车机信息Controller
 * 
 * @author zbw
 * @date 2022-07-13
 */
@RestController
@RequestMapping("/basicInfo/dumper")
public class DumperController extends BaseController
{
    @Autowired
    private IDumperService dumperService;

    /**
     * 查询翻车机信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dumper dumper)
    {
        startPage();
        List<Dumper> list = dumperService.selectDumperList(dumper);
        return getDataTable(list);
    }

    /**
     * 导出翻车机信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:export')")
    @Log(title = "翻车机信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dumper dumper)
    {
        List<Dumper> list = dumperService.selectDumperList(dumper);
        ExcelUtil<Dumper> util = new ExcelUtil<Dumper>(Dumper.class);
        util.exportExcel(response, list, "翻车机信息数据");
    }

    /**
     * 获取翻车机信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:query')")
    @GetMapping(value = "/{dumperId}")
    public AjaxResult getInfo(@PathVariable("dumperId") String dumperId)
    {
        return AjaxResult.success(dumperService.selectDumperByDumperId(dumperId));
    }

    /**
     * 新增翻车机信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:add')")
    @Log(title = "翻车机信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dumper dumper)
    {
        return toAjax(dumperService.insertDumper(dumper));
    }

    /**
     * 修改翻车机信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:edit')")
    @Log(title = "翻车机信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dumper dumper)
    {
        return toAjax(dumperService.updateDumper(dumper));
    }

    /**
     * 删除翻车机信息
     */
    @PreAuthorize("@ss.hasPermi('basicInfo:dumper:remove')")
    @Log(title = "翻车机信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dumperIds}")
    public AjaxResult remove(@PathVariable String[] dumperIds)
    {
        return toAjax(dumperService.deleteDumperByDumperIds(dumperIds));
    }
}
